refactor cases of "Declarator is reassigned in all
authortsteven4 <tsteven4@gmail.com>
Mon, 9 Jul 2018 17:19:51 +0000 (11:19 -0600)
committertsteven4 <tsteven4@gmail.com>
Mon, 9 Jul 2018 17:19:51 +0000 (11:19 -0600)
paths before being read"
when the declarator and the subsequent assignment can be joined.

48 files changed:
an1.cc
an1sym.h
arcdist.cc
bend.cc
cet.cc
compegps.cc
cst.cc
csv_util.cc
dmtlog.cc
explorist_ini.cc
formspec.cc
g7towin.cc
garmin_fs.cc
garmin_gpi.cc
garmin_txt.cc
garmin_xt.cc
globalsat_sport.cc
gpx.cc
holux.cc
html.cc
humminbird.cc
interpolate.cc
jtr.cc
kml.cc
lowranceusr4.cc
magproto.cc
mapsend.cc
mapsource.cc
ozi.cc
polygon.cc
psitrex.cc
saroute.cc
sbn.cc
skytraq.cc
smplrout.cc
stmsdf.cc
text.cc
tomtom.cc
tpo.cc
unicsv.cc
v900.cc
vecs.cc
vitosmt.cc
vitovtt.cc
wbt-200.cc
wfff_xml.cc
xcsv.cc
xmltag.cc

diff --git a/an1.cc b/an1.cc
index 1471ce014cb333dadfea0665f44ce900e65a2436..23ae464928bfacbddf5915ded79d3de394844ffe 100644 (file)
--- a/an1.cc
+++ b/an1.cc
@@ -129,12 +129,11 @@ ReadString(gbfile* f, short len)
 static void
 ReadGuid(gbfile* f, GUID* guid)
 {
-  int i = 0;
   guid->l = ReadLong(f);
-  for (i = 0; i < 3; i++) {
+  for (int i = 0; i < 3; i++) {
     guid->s[i] = ReadShort(f);
   }
-  for (i = 0; i < 6; i++) {
+  for (int i = 0; i < 6; i++) {
     guid->c[i] = ReadChar(f);
   }
 }
@@ -142,12 +141,11 @@ ReadGuid(gbfile* f, GUID* guid)
 static void
 WriteGuid(gbfile* f, GUID* guid)
 {
-  int i = 0;
   WriteLong(f, guid->l);
-  for (i = 0; i < 3; i++) {
+  for (int i = 0; i < 3; i++) {
     WriteShort(f, guid->s[i]);
   }
-  for (i = 0; i < 6; i++) {
+  for (int i = 0; i < 6; i++) {
     WriteChar(f, guid->c[i]);
   }
 }
@@ -283,8 +281,7 @@ static void Copy_AN1_Waypoint(void** vdwpt, void* vwpt)
 
 static an1_waypoint_record* Alloc_AN1_Waypoint()
 {
-  an1_waypoint_record* result = nullptr;
-  result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1);
+  an1_waypoint_record* result = (an1_waypoint_record*)xcalloc(sizeof(*result), 1);
   result->fs.type = FS_AN1W;
   result->fs.copy = Copy_AN1_Waypoint;
   result->fs.destroy = Destroy_AN1_Waypoint;
@@ -309,8 +306,7 @@ static void Copy_AN1_Vertex(void** vdvert, void* vvert)
 
 static an1_vertex_record* Alloc_AN1_Vertex()
 {
-  an1_vertex_record* result = nullptr;
-  result = (an1_vertex_record*)xcalloc(sizeof(*result), 1);
+  an1_vertex_record* result = (an1_vertex_record*)xcalloc(sizeof(*result), 1);
   result->fs.type = FS_AN1V;
   result->fs.copy = Copy_AN1_Vertex;
   result->fs.destroy = Destroy_AN1_Vertex;
@@ -339,8 +335,7 @@ static void Copy_AN1_Line(void** vdline, void* vline)
 
 static an1_line_record* Alloc_AN1_Line()
 {
-  an1_line_record* result = nullptr;
-  result = (an1_line_record*)xcalloc(sizeof(*result), 1);
+  an1_line_record* result = (an1_line_record*)xcalloc(sizeof(*result), 1);
   result->fs.type = FS_AN1L;
   result->fs.copy = Copy_AN1_Line;
   result->fs.destroy = Destroy_AN1_Line;
@@ -684,15 +679,12 @@ static void Write_AN1_Bitmaps(gbfile* f)
 
 static void Read_AN1_Waypoints(gbfile* f)
 {
-  unsigned long count = 0;
-  unsigned long i = 0;
-  an1_waypoint_record* rec = nullptr;
   Waypoint* wpt_tmp;
   char* icon = nullptr;
   ReadShort(f);
-  count = ReadLong(f);
-  for (i = 0; i < count; i++) {
-    rec = Alloc_AN1_Waypoint();
+  unsigned long count = ReadLong(f);
+  for (unsigned long i = 0; i < count; i++) {
+    an1_waypoint_record* rec = Alloc_AN1_Waypoint();
     Read_AN1_Waypoint(f, rec);
     wpt_tmp = new Waypoint;
 
@@ -832,18 +824,13 @@ static void Write_AN1_Waypoints(gbfile* f)
 
 static void Read_AN1_Lines(gbfile* f)
 {
-  unsigned long count = 0;
-  unsigned long i = 0;
-  unsigned long j = 0;
-  an1_line_record* rec = nullptr;
-  an1_vertex_record* vert = nullptr;
   route_head* rte_head;
   Waypoint* wpt_tmp;
 
   ReadShort(f);
-  count = ReadLong(f);
-  for (i = 0; i < count; i++) {
-    rec = Alloc_AN1_Line();
+  unsigned long count = ReadLong(f);
+  for (unsigned long i = 0; i < count; i++) {
+    an1_line_record* rec = Alloc_AN1_Line();
     Read_AN1_Line(f, rec);
     /* create route rec */
     rte_head = route_head_alloc();
@@ -860,8 +847,8 @@ static void Read_AN1_Lines(gbfile* f)
     rte_head->rte_name = rec->name;
     fs_chain_add(&rte_head->fs, (format_specific_data*)rec);
     route_add_head(rte_head);
-    for (j = 0; j < (unsigned) rec->pointcount; j++) {
-      vert = Alloc_AN1_Vertex();
+    for (unsigned long j = 0; j < (unsigned) rec->pointcount; j++) {
+      an1_vertex_record* vert = Alloc_AN1_Vertex();
       Read_AN1_Vertex(f, vert);
 
       /* create route point */
@@ -903,9 +890,8 @@ Write_One_AN1_Line(const route_head* rte)
 {
   an1_line_record* rec;
   int local;
-  format_specific_data* fs = nullptr;
 
-  fs = fs_chain_find(rte->fs, FS_AN1L);
+  format_specific_data* fs = fs_chain_find(rte->fs, FS_AN1L);
 
   if (fs) {
     rec = (an1_line_record*)(void*)fs;
@@ -1000,9 +986,8 @@ Write_One_AN1_Vertex(const Waypoint* wpt)
 {
   an1_vertex_record* rec;
   int local;
-  format_specific_data* fs = nullptr;
 
-  fs = fs_chain_find(wpt->fs, FS_AN1V);
+  format_specific_data* fs = fs_chain_find(wpt->fs, FS_AN1V);
 
   if (fs) {
     rec = (an1_vertex_record*)(void*)fs;
@@ -1139,16 +1124,12 @@ static void
 Init_Road_Changes()
 {
   int count = 0;
-  char* strType = nullptr;
-  char* name = nullptr;
-  char* bar = nullptr;
-  char* copy = nullptr;
   Free_Road_Changes();
 
   if (!road_changes || !road_changes[0]) {
     return;
   }
-  bar = strchr(road_changes, '!');
+  char* bar = strchr(road_changes, '!');
   while (bar) {
     count++;
     bar = strchr(bar+1, '!');
@@ -1162,16 +1143,16 @@ Init_Road_Changes()
   roadchanges[count].type = 0;
   roadchanges[count].name = nullptr;
 
-  copy = xstrdup(road_changes);
+  char* copy = xstrdup(road_changes);
   bar = copy;
 
   while (count) {
     count--;
-    name = bar;
+    char* name = bar;
     bar = strchr(name, '!');
     *bar = '\0';
     bar++;
-    strType = bar;
+    char* strType = bar;
     bar = strchr(strType, '!');
     if (bar) {
       *bar = '\0';
index ee0e02e4e8e99fe655fbc66a45947e16b15e6a77..5ccbab92baa5318b505f4cc9e35dbd352a6cdd11 100644 (file)
--- a/an1sym.h
+++ b/an1sym.h
@@ -710,8 +710,7 @@ static struct defguid {
 
 static int FindIconByName(const char* name, GUID* guid)
 {
-  unsigned int i = 0;
-  for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
+  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
     if (!case_ignore_strcmp(name, default_guids[i].name)) {
       memcpy(guid, &(default_guids[i].guid), sizeof(GUID));
       return 1;
@@ -722,8 +721,7 @@ static int FindIconByName(const char* name, GUID* guid)
 
 static int FindIconByGuid(GUID* guid, char** name)
 {
-  unsigned int i = 0;
-  for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
+  for (unsigned int i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) {
     if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) {
       *name = const_cast<char*>(default_guids[i].name);
       return 1;
index 0e2c19ec14da61e76b22e231d2f8a48035b6f266..86145fcd5a72f27fba417d89ce56c77e27e090d5 100644 (file)
@@ -125,8 +125,6 @@ void ArcDistanceFilter::process()
 
     arcpt2->latitude = arcpt2->longitude = BADVAL;
     while ((line = gbfgetstr(file_in))) {
-      int argsfound = 0;
-
       fileline++;
 
       char* pound = strchr(line, '#');
@@ -138,7 +136,7 @@ void ArcDistanceFilter::process()
       }
 
       arcpt2->latitude = arcpt2->longitude = BADVAL;
-      argsfound = sscanf(line, "%lf %lf", &arcpt2->latitude, &arcpt2->longitude);
+      int argsfound = sscanf(line, "%lf %lf", &arcpt2->latitude, &arcpt2->longitude);
 
       if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) {
         warning(MYNAME ": Warning: Arc file contains unusable vertex on line %d.\n", fileline);
diff --git a/bend.cc b/bend.cc
index b40c752dc08b0c410d24612dbf64ceeba9c8b33e..d66525f491c74c14fcc0a8d1662372048d88e22a 100644 (file)
--- a/bend.cc
+++ b/bend.cc
@@ -56,7 +56,6 @@ Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, double lat_orig,
   double frac;
   double lat_dest;
   double long_dest;
-  Waypoint* wpt_dest = nullptr;
   distance = radtometers(distance);
   if (distance <= maxDist) {
     return nullptr;
@@ -67,7 +66,7 @@ Waypoint* BendFilter::create_wpt_dest(const Waypoint* wpt_orig, double lat_orig,
   linepart(lat_orig, long_orig, lat_orig_adj, long_orig_adj, frac,
            &lat_dest, &long_dest);
 
-  wpt_dest = new Waypoint(*wpt_orig);
+  Waypoint* wpt_dest = new Waypoint(*wpt_orig);
   wpt_dest->latitude = DEG(lat_dest);
   wpt_dest->longitude = DEG(long_dest);
 
@@ -113,7 +112,6 @@ void BendFilter::process_route(const route_head* route_orig, route_head* route_d
 
       double lat_orig_next = RAD(wpt_orig_next->latitude);
       double long_orig_next = RAD(wpt_orig_next->longitude);
-      Waypoint* wpt_dest_next = nullptr;
 
       if (is_small_angle(lat_orig, long_orig, lat_orig_prev,
                          long_orig_prev, lat_orig_next, long_orig_next)) {
@@ -126,8 +124,8 @@ void BendFilter::process_route(const route_head* route_orig, route_head* route_d
           route_add_wpt(route_dest, wpt_dest_prev);
         }
 
-        wpt_dest_next = create_wpt_dest(wpt_orig,
-                                        lat_orig, long_orig, lat_orig_next, long_orig_next);
+        Waypoint* wpt_dest_next = create_wpt_dest(wpt_orig,
+                                                   lat_orig, long_orig, lat_orig_next, long_orig_next);
         if (wpt_dest_next != nullptr) {
           route_add_wpt(route_dest, wpt_dest_next);
 
diff --git a/cet.cc b/cet.cc
index 4e44ffcb824d089d4957048251d4d16fed462b4e..9b2821f6a7a03a9d3f951a4157bf3bd02902bfd8 100644 (file)
--- a/cet.cc
+++ b/cet.cc
@@ -153,9 +153,8 @@ cet_utf8_to_ucs4(const char* str, int* bytes, int* value)
   } else {
     unsigned char bits = 0xc0;
     unsigned char mask = 0xe0;
-    int len = 0;
 
-    for (len = 1; len <= 6; len++) {           /* outer loop, test UTF-8 frame */
+    for (int len = 1; len <= 6; len++) {               /* outer loop, test UTF-8 frame */
       if ((*cp & mask) == bits) {
         int i = len;
         while (i-- > 0) {
index 362df191a2d56d202b27b0eb2d0e8fe5de195637..a5eb1dac6127c65fcf3fee7d05adc5431cbaffe9 100644 (file)
@@ -400,13 +400,12 @@ compegps_data_read(void)
   route_head* track = nullptr;
 
   while ((buff = gbfgetstr(fin))) {
-    char* cin = buff;
     char* ctail;
 
     if ((line++ == 0) && fin->unicode) {
       cet_convert_init(CET_CHARSET_UTF8, 1);
     }
-    cin = lrtrim(buff);
+    char* cin = lrtrim(buff);
     if (strlen(cin) == 0) {
       continue;
     }
diff --git a/cst.cc b/cst.cc
index be13a32ffa30f95fbedcb9a08af68b20e98df1e4..3b2e12f2f24f800e51c1b361018138aef70ea075 100644 (file)
--- a/cst.cc
+++ b/cst.cc
@@ -165,12 +165,10 @@ cst_data_read()
   Waypoint* wpt = nullptr;
 
   while ((buff = gbfgetstr(fin))) {
-    char* cin = buff;
-
     if ((line++ == 0) && fin->unicode) {
       cet_convert_init(CET_CHARSET_UTF8, 1);
     }
-    cin = lrtrim(buff);
+    char* cin = lrtrim(buff);
     if (strlen(cin) == 0) {
       continue;
     }
index 6bfcc9349daf9d64b62c81f0493ff6b1fc118f5f..4f902cb78630f475cb6b5b05d6230ffdb06d6fae 100644 (file)
@@ -191,7 +191,6 @@ char*
 csv_stringtrim(const char* string, const char* enclosure, int strip_max)
 {
   static const char* p1 = nullptr;
-  char* p2 = nullptr;
   char* tmp = xxstrdup(string,file,line);
   size_t elen;
   int stripped = 0;
@@ -206,7 +205,7 @@ csv_stringtrim(const char* string, const char* enclosure, int strip_max)
     elen = strlen(enclosure);
   }
 
-  p2 = tmp + strlen(tmp) - 1;
+  char* p2 = tmp + strlen(tmp) - 1;
   p1 = tmp;
 
   /* trim off trailing whitespace */
@@ -638,17 +637,11 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which)
 QString
 dec_to_human(const char* format, const char* dirs, double val)
 {
-  char* subformat = nullptr;
-  const char* formatptr = nullptr;
-  char* percent = nullptr;
-  char* type = nullptr;
-
   int  index = 0;
   int  intvals[3] = {0,0,0};
   double  dblvals[3] = {0,0,0};
-  int  sign = 0;
 
-  sign = (val < 0) ? 0 : 1;
+  int sign = (val < 0) ? 0 : 1;
 
   dblvals[0] = fabs(val);
   intvals[0] = (int)dblvals[0];
@@ -657,16 +650,16 @@ dec_to_human(const char* format, const char* dirs, double val)
   dblvals[2] = 60*(dblvals[1]-intvals[1]);
   intvals[2] = (int)dblvals[2];
 
-  subformat = (char*) xmalloc(strlen(format)+2);
-  formatptr = format;
+  char* subformat = (char*) xmalloc(strlen(format)+2);
+  const char* formatptr = format;
 
   QString buff;
 
   while (formatptr && *formatptr) {
     strcpy(subformat, formatptr);
-    percent = strchr(subformat, '%');
+    char* percent = strchr(subformat, '%');
     if (percent) {
-      type = percent+1+strcspn(percent+1, "cdiouxXeEfgG%");
+      char* type = percent+1+strcspn(percent+1, "cdiouxXeEfgG%");
       *(type+1) = '\0';
       switch (*type) {
       case 'c':
index e68535074004ddf80a3a094ceacfedd123623621..b39f0a4b36e98cd264280e501cf6c3882d6ca882 100644 (file)
--- a/dmtlog.cc
+++ b/dmtlog.cc
@@ -584,7 +584,6 @@ read_CTrackFile(const int version)
 static int
 inflate_buff(const char* buff, const size_t size, char** out_buff)
 {
-  int res = Z_OK;
   z_stream strm;
   char out[DEFLATE_BUFF_SIZE];
   char* cout = nullptr;
@@ -597,7 +596,7 @@ inflate_buff(const char* buff, const size_t size, char** out_buff)
   strm.avail_in = 0;
   strm.next_in = Z_NULL;
 
-  res = inflateInit(&strm);
+  int res = inflateInit(&strm);
   if (res != Z_OK) {
     return res;
   }
index 472117a43c181b4c53e09ad09c1aa0c9227636f2..3db42ae5d6297718623d457c3a880540ead18e56 100644 (file)
@@ -16,7 +16,6 @@ explorist_read_value(const char* section, const char* key)
 static mag_info*
 explorist_ini_try(const char* path)
 {
-  mag_info* info = nullptr;
   char* inipath;
   char* s;
 
@@ -27,7 +26,7 @@ explorist_ini_try(const char* path)
     return nullptr;
   }
 
-  info = (mag_info*) xmalloc(sizeof(mag_info));
+  mag_info* info = (mag_info*) xmalloc(sizeof(mag_info));
   info->geo_path = nullptr;
   info->track_path = nullptr;
   info->waypoint_path = nullptr;
index 1fcd1101d8ce061e4902731ba8d64c78710ee0f9..331b69a9748f46f4b592f0183c5555be5526425f 100644 (file)
@@ -39,9 +39,8 @@ format_specific_data* fs_chain_copy(format_specific_data* source)
 void fs_chain_destroy(format_specific_data* chain)
 {
   format_specific_data* cur = chain;
-  format_specific_data* next = nullptr;
   while (cur) {
-    next = cur->next;
+    format_specific_data* next = cur->next;
     cur->destroy(cur);
     cur = next;
   }
index 16cfef3b69c35c7c70117791569e4cb939a99d54..ecf5620ac4b7b626d309f6e5f8be1927c0cf52bf 100644 (file)
@@ -416,14 +416,13 @@ data_read(void)
   route_head* head = nullptr;
 
   while ((buff = gbfgetstr(fin))) {
-    char* cin = buff;
     char* cdata;
 
     if ((line++ == 0) && fin->unicode) {
       cet_convert_init(CET_CHARSET_UTF8, 1);
     }
 
-    cin = lrtrim(buff);
+    char* cin = lrtrim(buff);
     if (!*cin) {
       continue;
     }
index 18443b5e942adcde519a51f5a5f0c69738289cc0..80d38f68f1c76e9d2076f694650a0a4a4e3a9050 100644 (file)
@@ -36,9 +36,7 @@
 garmin_fs_t*
 garmin_fs_alloc(const int protocol)
 {
-  garmin_fs_t* result = nullptr;
-
-  result = (garmin_fs_t*)xcalloc(1, sizeof(*result));
+  garmin_fs_t* result = (garmin_fs_t*)xcalloc(1, sizeof(*result));
   result->fs.type = FS_GMSD;
   result->fs.copy = (fs_copy) garmin_fs_copy;
   result->fs.destroy = garmin_fs_destroy;
@@ -432,9 +430,7 @@ garmin_fs_merge_category(const char* category_name, Waypoint* waypt)
 void
 garmin_fs_garmin_after_read(const GPS_PWay way, Waypoint* wpt, const int protoid)
 {
-  garmin_fs_t* gmsd = nullptr;
-
-  gmsd = garmin_fs_alloc(protoid);
+  garmin_fs_t* gmsd = garmin_fs_alloc(protoid);
   fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
 
   /* nothing happens until gmsd is allocated some lines above */
index 5f0612168351c75dc4270387b6126972ea324371..8775da69c45d2e9e4629ffac8e8f28c766f65652 100644 (file)
@@ -283,7 +283,6 @@ gpi_read_string_old(const char* field)
     if (first == 0) {
       short l1;
       short l2;
-      char* res2 = nullptr;
       char lc1[3] = "";
       char lc2[3] = "";
 
@@ -292,7 +291,7 @@ gpi_read_string_old(const char* field)
 
       char* res1 = gpi_read_lc_string_old(lc1,  &l1);
       if ((l1 + 4) < l0) { // dual language?
-        res2 = gpi_read_lc_string_old(lc2,  &l2);
+        char* res2 = gpi_read_lc_string_old(lc2,  &l2);
         is_fatal((l1 + 4 + l2 + 4 != l0),
                  MYNAME ": Error out of sync (wrong size %d/%d/%d) on field '%s'!", l0, l1, l2, field);
         if (opt_lang && (strcmp(opt_lang, lc1) == 0)) {
index e084eb2b49ae72499ecfcc427388170ed5c7ea28..96585c46f7918478b0376c11eace04d6fac95699 100644 (file)
@@ -1108,12 +1108,11 @@ parse_waypoint()
   char* str;
   int column = -1;
   Waypoint* wpt;
-  garmin_fs_p gmsd = nullptr;
 
   bind_fields(waypt_header);
 
   wpt = new Waypoint;
-  gmsd = garmin_fs_alloc(-1);
+  garmin_fs_p gmsd = garmin_fs_alloc(-1);
   fs_chain_add(&wpt->fs, (format_specific_data*) gmsd);
 
   while ((str = csv_lineparse(nullptr, "\t", "", column++))) {
index 9e5e2713bfa2e5fe9b888b4559cc4df0b506bd23..0143078d0b6624a72a4da7ad1ecd505eb36faa59 100644 (file)
@@ -87,7 +87,6 @@ static uint16_t
 format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color)
 {
   int          method = 0;
-  uint16_t     trackbytes = 0, TrackPoints = 0;
   uint8_t      spam = 0;
   int32_t              TrackMaxLat = 0, TrackMaxLon = 0, TrackMinLat = 0, TrackMinLon = 0;
   char         trk_name[30]="";
@@ -105,8 +104,8 @@ format_garmin_xt_rd_st_attrs(char* p_trk_name, uint8_t* p_track_color)
   // set to RED if not specified
   *p_track_color=9;
 
-  trackbytes = gbfgetuint16(fin);
-  TrackPoints = gbfgetuint16(fin);
+  uint16_t trackbytes = gbfgetuint16(fin);
+  uint16_t TrackPoints = gbfgetuint16(fin);
   (void) TrackPoints;
 
   switch (method) {
@@ -171,8 +170,6 @@ format_garmin_xt_decrypt_trk_blk(int Count, uint8_t TrackBlock[])
 static void
 format_garmin_xt_decomp_trk_blk(uint8_t ii, uint8_t TrackBlock[], double* Ele, double* Lat, double* Lon, uint32_t* Time)
 {
-  uint32_t     LatLW = 0, LonLW = 0, TimeLW = 0;
-  double               LatF = 0, LonF = 0;
   uint16_t     PrevEleW;
 
   //printf("%d %d %d %d %d %d\n", TrackBlock[0], TrackBlock[1], TrackBlock[2], TrackBlock[3], TrackBlock[4], TrackBlock[5]);
@@ -181,29 +178,29 @@ format_garmin_xt_decomp_trk_blk(uint8_t ii, uint8_t TrackBlock[], double* Ele, d
   PrevEleW = PrevEleW + TrackBlock[(ii - 1) * 12 ];
   *Ele = (double)PrevEleW * GARMIN_XT_ELE - 1500;
 
-  LatLW = TrackBlock[(ii - 1) * 12 + 4];
+  uint32_t LatLW = TrackBlock[(ii - 1) * 12 + 4];
   LatLW = LatLW << 8;
   LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 3];
   LatLW = LatLW << 8;
   LatLW = LatLW + TrackBlock[(ii - 1) * 12 + 2];
-  LatF = (double)LatLW;
+  double LatF = (double)LatLW;
   if (LatF > 8388608) {
     LatF = LatF - 16777216;
   }
   *Lat = LatF * 360 / 16777216;
 
-  LonLW = TrackBlock[(ii-1)*12+7];
+  uint32_t LonLW = TrackBlock[(ii-1)*12+7];
   LonLW = LonLW << 8;
   LonLW = LonLW+TrackBlock[(ii-1)*12+6];
   LonLW = LonLW << 8;
   LonLW = LonLW+TrackBlock[(ii-1)*12+5];
-  LonF = (double)LonLW;
+  double LonF = (double)LonLW;
   if (LonF>8388608) {
     LonF = LonF - 16777216;
   }
   *Lon = LonF * 360 / 16777216;
 
-  TimeLW = TrackBlock[(ii - 1) * 12 + 11];
+  uint32_t TimeLW = TrackBlock[(ii - 1) * 12 + 11];
   TimeLW = TimeLW << 8;
   TimeLW = TimeLW+TrackBlock[(ii - 1) * 12 + 10];
   TimeLW = TimeLW << 8;
@@ -234,8 +231,7 @@ static void
 format_garmin_xt_proc_strk()
 {
   int          Count = 0; // Used to obtain number of read bytes
-  int          NumberOfTracks = 0, TracksCompleted = 0; // Number of tracks in the file and number of processed tracks
-  uint16_t     trackbytes = 0; // Bytes in track
+  int TracksCompleted = 0; // Number of tracks in the file and number of processed tracks
   uint8_t      TrackBlock[STRK_BLOCK_SIZE + 1]; // File Block
   uint8_t      ii; // temp variable
   double               Lat = 0, Lon = 0; // wpt data
@@ -248,7 +244,7 @@ format_garmin_xt_proc_strk()
   gbfseek(fin, 12, SEEK_SET);
 
   // read # of tracks
-  NumberOfTracks = gbfgetuint16(fin);
+  int NumberOfTracks = gbfgetuint16(fin);
 
   // Skip 2 bytes
   gbfseek(fin, 2, SEEK_CUR);
@@ -261,7 +257,7 @@ format_garmin_xt_proc_strk()
     trk_name = (char*) xmalloc(30);
 
     // Generate Track Header
-    trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50;
+    uint16_t trackbytes = format_garmin_xt_rd_st_attrs(trk_name, &trk_color) - 50;
 
     tmp_track = route_head_alloc();
     // update track color
@@ -338,10 +334,6 @@ format_garmin_xt_proc_strk()
 static void
 format_garmin_xt_proc_atrk()
 {
-  uint16_t     block=0, uu=0;
-  uint32_t     Lat=0, Lon=0;
-  uint32_t     Tim=0;
-  double               LatF = 0, LonF = 0, AltF = 0;
   Waypoint*    wpt;
   int          method = 0;
   unsigned char        buf[3];
@@ -366,29 +358,29 @@ format_garmin_xt_proc_atrk()
   num_trackpoints = gbfgetuint32(fin);
 
   while (num_trackpoints--) {
-    block = gbfgetuint16(fin);
+    uint16_t block = gbfgetuint16(fin);
     if (block != 0x0c) {
       break;
     }
 
     gbfread(&buf, 3, DATABLOCKSIZE, fin); //1. Lat
-    Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16);
+    uint32_t Lat = buf[0] | (buf[1] << 8) | (buf[2] << 16);
     gbfread(&buf, 3, DATABLOCKSIZE, fin); //2. Lon
-    Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16);
+    uint32_t Lon = buf[0] | (buf[1] << 8) | (buf[2] << 16);
 
-    uu = gbfgetuint16(fin);
-    Tim = gbfgetuint32(fin);
+    uint16_t uu = gbfgetuint16(fin);
+    uint32_t Tim = gbfgetuint32(fin);
 
     Tim += 631065600; // adjustment to UnixTime
-    LatF = Lat;
+    double LatF = Lat;
     if (LatF>8388608) {
       LatF -= 16777216;
     };
-    LonF = Lon;
+    double LonF = Lon;
     if (LonF>8388608) {
       LonF -= 16777216;
     };
-    AltF = (double)uu * GARMIN_XT_ELE - 1500;
+    double AltF = (double)uu * GARMIN_XT_ELE - 1500;
 
     //create new waypoint
     wpt = new Waypoint;
index 269fcbfbb20130f6baf323c5a9192180042d8f24..7b7bdcce0f7dc0a50a460a1826bc35ea9a38b6a2 100644 (file)
@@ -576,8 +576,7 @@ track_read()
 
         uint8_t trackDeviceCommand;
         int track_length;
-        uint8_t* track_payload = nullptr;
-        track_payload = globalsat_read_package(&track_length, &trackDeviceCommand);
+        uint8_t* track_payload = globalsat_read_package(&track_length, &trackDeviceCommand);
         is_fatal(((track_length == 0) || (track_payload == nullptr)) , "tracklength in 0 bytes or payload nonexistant");
         //      printf("Got track package!!! Train data\n");
 
diff --git a/gpx.cc b/gpx.cc
index d67f43f7c63d354befd580aa347c836ac8a261a1..4f90f7104d28c8aa672f59d8ef17f80280c041f3 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
@@ -806,11 +806,9 @@ xml_parse_time(const QString& dateTimeString)
   int off_hr = 0;
   int off_min = 0;
   int off_sign = 1;
-  char* offsetstr = nullptr;
-  char* pointstr = nullptr;
   char* timestr = xstrdup(dateTimeString);
 
-  offsetstr = strchr(timestr, 'Z');
+  char* offsetstr = strchr(timestr, 'Z');
   if (offsetstr) {
     /* zulu time; offsets stay at defaults */
     *offsetstr = '\0';
@@ -835,7 +833,7 @@ xml_parse_time(const QString& dateTimeString)
   }
 
   double fsec = 0;
-  pointstr = strchr(timestr, '.');
+  char* pointstr = strchr(timestr, '.');
   if (pointstr) {
     sscanf(pointstr, "%le", &fsec);
 #if 0
@@ -1455,7 +1453,6 @@ fprint_xml_chain(xml_tag* tag, const Waypoint* wpt)
 
 void free_gpx_extras(xml_tag* tag)
 {
-  xml_tag* next = nullptr;
   char** ap;
 
   while (tag) {
@@ -1472,7 +1469,7 @@ void free_gpx_extras(xml_tag* tag)
       xfree(tag->attributes);
     }
 
-    next = tag->sibling;
+    xml_tag* next = tag->sibling;
     delete tag;
     tag = next;
   }
index 46017dbe9f350f7edd47d9c9262968152ca18086..ae5e9a79221c2937fb8ab08dc5cafce919343f28 100644 (file)
--- a/holux.cc
+++ b/holux.cc
@@ -155,7 +155,6 @@ static const char* mknshort(const char* stIn,unsigned int sLen)
 #define MAX_STRINGLEN 255
   static char strOut[MAX_STRINGLEN];
   char strTmp[MAX_STRINGLEN];
-  char* shortstr = nullptr;
 
   if (sLen > MAX_STRINGLEN) {
     return (stIn);
@@ -168,7 +167,7 @@ static const char* mknshort(const char* stIn,unsigned int sLen)
   setshort_length(mkshort_handle, sLen);
   setshort_mustuniq(mkshort_handle, 0);
 
-  shortstr = mkshort(mkshort_handle, stIn);
+  char* shortstr = mkshort(mkshort_handle, stIn);
   strcpy(strTmp,shortstr);
   xfree(shortstr);
 
diff --git a/html.cc b/html.cc
index ee7907f4c8403dbd92cf25927b35818ad41d1fce..2e20c59502430a1b040def7a0293f5558536f5cc 100644 (file)
--- a/html.cc
+++ b/html.cc
@@ -85,7 +85,6 @@ html_disp(const Waypoint* wpt)
   int32_t utmz;
   double utme, utmn;
   char utmzc;
-  fs_xml* fs_gpx = nullptr;
 
 
   GPS_Math_WGS84_To_UTM_EN(wpt->latitude, wpt->longitude,
@@ -151,22 +150,19 @@ html_disp(const Waypoint* wpt)
     gbfprintf(file_out, "<p class=\"gpsbabelnotes\">%s</p>\n", CSTRc(wpt->notes));
   }
 
-  fs_gpx = nullptr;
+  fs_xml* fs_gpx = nullptr;
   if (includelogs) {
     fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
   }
 
   if (fs_gpx && fs_gpx->tag) {
     xml_tag* root = fs_gpx->tag;
-    xml_tag* curlog = nullptr;
-    xml_tag* logpart = nullptr;
-    curlog = xml_findfirst(root, "groundspeak:log");
+    xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
     while (curlog) {
       time_t logtime = 0;
-      struct tm* logtm = nullptr;
       gbfprintf(file_out, "<p class=\"gpsbabellog\">\n");
 
-      logpart = xml_findfirst(curlog, "groundspeak:type");
+      xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
       if (logpart) {
         gbfprintf(file_out, "<span class=\"gpsbabellogtype\">%s</span> by ", CSTR(logpart->cdata));
       }
@@ -181,7 +177,7 @@ html_disp(const Waypoint* wpt)
       logpart = xml_findfirst(curlog, "groundspeak:date");
       if (logpart) {
         logtime = xml_parse_time(logpart->cdata).toTime_t();
-        logtm = localtime(&logtime);
+        struct tm* logtm = localtime(&logtime);
         if (logtm) {
           gbfprintf(file_out,
                     "<span class=\"gpsbabellogdate\">%04d-%02d-%02d</span><br>\n",
@@ -193,10 +189,9 @@ html_disp(const Waypoint* wpt)
 
       logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
       if (logpart) {
-        char* coordstr = nullptr;
         double lat = 0;
         double lon = 0;
-        coordstr = xml_attribute(logpart, "lat");
+        char* coordstr = xml_attribute(logpart, "lat");
         if (coordstr) {
           lat = atof(coordstr);
         }
@@ -213,10 +208,8 @@ html_disp(const Waypoint* wpt)
 
       logpart = xml_findfirst(curlog, "groundspeak:text");
       if (logpart) {
-        char* encstr = nullptr;
-        int encoded = 0;
-        encstr = xml_attribute(logpart, "encoded");
-        encoded = (toupper(encstr[0]) != 'F');
+        char* encstr = xml_attribute(logpart, "encoded");
+        int encoded = (toupper(encstr[0]) != 'F');
 
         QString s;
         if (html_encrypt && encoded) {
index fa0d05f7c9b3a05c4b9e16a14f61a8be4a335881..63bd4192d7d615a179cfab87dc16678a7e18303f 100644 (file)
@@ -378,7 +378,6 @@ humminbird_read_track(gbfile* fin)
   humminbird_trk_point_t* points;
   route_head* trk;
   Waypoint* first_wpt;
-  int max_points = 0;
   int32_t accum_east;
   int32_t accum_north;
   double g_lat;
@@ -401,7 +400,7 @@ humminbird_read_track(gbfile* fin)
   th.ne_east     = be_read32(&th.ne_east);
   th.ne_north    = be_read32(&th.ne_north);
 
-  max_points = (131080 - sizeof(uint32_t) - sizeof(th)) / sizeof(humminbird_trk_point_t);
+  int max_points = (131080 - sizeof(uint32_t) - sizeof(th)) / sizeof(humminbird_trk_point_t);
 
   if (th.num_points == max_points + 1) {
     th.num_points--;
@@ -498,7 +497,6 @@ humminbird_read_track_old(gbfile* fin)
   humminbird_trk_point_old_t* points;
   route_head* trk;
   Waypoint* first_wpt;
-  int max_points = 0;
   int32_t accum_east;
   int32_t accum_north;
   double g_lat;
@@ -521,7 +519,7 @@ humminbird_read_track_old(gbfile* fin)
 
   // These files are always 8048 bytes long. Note that that's the value
   // of the second 16-bit word in the signature.
-  max_points = (file_len - (sizeof(th) + sizeof(uint32_t) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t);
+  int max_points = (file_len - (sizeof(th) + sizeof(uint32_t) + TRK_NAME_LEN)) / sizeof(humminbird_trk_point_old_t);
 
   if (th.num_points > max_points) {
     fatal(MYNAME ": Too many track points! (%d)\n", th.num_points);
index c43b3fb25a5209fe4370dc20f769599f8a8ee661..219a238f464a07ae79fe8aeaa21797c8fb1b42df 100644 (file)
@@ -55,7 +55,6 @@ void InterpolateFilter::process()
   }
 
   QUEUE_FOR_EACH(backuproute, elem, tmp) {
-    bool first = false;
     route_head* rte_old = (route_head*)elem;
 
     route_head* rte_new = route_head_alloc();
@@ -68,7 +67,7 @@ void InterpolateFilter::process()
     } else {
       track_add_head(rte_new);
     }
-    first = 1;
+    bool first = 1;
     QUEUE_FOR_EACH(&rte_old->waypoint_list, elem2, tmp2) {
       Waypoint* wpt = (Waypoint*)elem2;
       if (first) {
diff --git a/jtr.cc b/jtr.cc
index d85ede24d5be3c30b32dadc5172cd8bf26ecb3a1..21a6a84c12e4eecb76887730ac13ad64cfa53136 100644 (file)
--- a/jtr.cc
+++ b/jtr.cc
@@ -106,7 +106,6 @@ jtr_read()
     Waypoint* wpt;
     struct tm tm;
     char* tmp;
-    int column = -1;
     char valid = 'V';
     double lat, lon;
     float speed, course, mcourse, mvar, mdev;
@@ -131,7 +130,7 @@ jtr_read()
     speed = course = mcourse = mvar = mdev = -1;
     mvardir = mdevdir = 0;
 
-    column = -1;
+    int column = -1;
     tmp = str;
     while ((str = csv_lineparse(tmp, ",", "", column++))) {
       tmp = nullptr;
diff --git a/kml.cc b/kml.cc
index 6602f4f8e836b08cfae0d02e264347a212acf267..40968faf6ba22b3298a44c1bb4b52737789079a8 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -356,13 +356,12 @@ void wpt_ts_end(xg_string args, const QXmlStreamAttributes*)
 
 void wpt_coord(const QString& args, const QXmlStreamAttributes*)
 {
-  int n = 0;
   double lat, lon, alt;
   if (! wpt_tmp) {
     return;
   }
   // Alt is actually optional.
-  n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt);
+  int n = sscanf(CSTRc(args), "%lf,%lf,%lf", &lon, &lat, &alt);
   if (n >= 2) {
     wpt_tmp->latitude = lat;
     wpt_tmp->longitude = lon;
@@ -1417,20 +1416,17 @@ static QString kml_geocache_get_logs(const Waypoint* wpt)
   QString r;
 
   fs_xml* fs_gpx = (fs_xml*)fs_chain_find(wpt->fs, FS_GPX);
-  xml_tag* root = nullptr;
-  xml_tag* curlog = nullptr;
-  xml_tag* logpart = nullptr;
 
   if (!fs_gpx) {
     return r;
   }
 
-  root = fs_gpx->tag;
-  curlog = xml_findfirst(root, "groundspeak:log");
+  xml_tag* root = fs_gpx->tag;
+  xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
   while (curlog) {
     // Unless we have a broken GPX input, these logparts
     // branches will always be taken.
-    logpart = xml_findfirst(curlog, "groundspeak:type");
+    xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
     if (logpart) {
       r = r + "<p><b>" + logpart->cdata + "</b>";
     }
@@ -1450,9 +1446,8 @@ static QString kml_geocache_get_logs(const Waypoint* wpt)
 
     logpart = xml_findfirst(curlog, "groundspeak:text");
     if (logpart) {
-      int encoded = 0;
       char* encstr = xml_attribute(logpart, "encoded");
-      encoded = (toupper(encstr[0]) != 'F');
+      int encoded = (toupper(encstr[0]) != 'F');
 
       QString s;
       if (html_encrypt && encoded) {
index 88b6657e96352311fa5ab46f09a8577adac3999e..310cf8fb59d7ab2631aa06517107f3cdec4c7754 100644 (file)
@@ -115,9 +115,7 @@ lowranceusr4_readstr(char* buf, const int maxlen, gbfile* file, int bytes_per_ch
 static void
 lowranceusr4_writestr(const QString& buf, gbfile* file, unsigned int bytes_per_char)
 {
-  unsigned int len = 0;
-
-  len = buf.length();
+  unsigned int len = buf.length();
 
   if (0xffffffff / bytes_per_char < len) {
     /* be pedantic and check for the unlikely event that we are asked
index 3bcae258b7efb1c1e971d2a6810183282474a2f2..70725dec2090f7edf50e9dbf3e29bff0f55e4b9e 100644 (file)
@@ -1438,11 +1438,10 @@ void mag_track_disp(const Waypoint* waypointp)
   int hms=0;
   int fracsec=0;
   int date=0;
-  struct tm* tm = nullptr;
 
   ilat = waypointp->latitude;
   ilon = waypointp->longitude;
-  tm = nullptr;
+  struct tm* tm = nullptr;
   if (waypointp->creation_time.isValid()) {
     const time_t ct = waypointp->GetCreationTime().toTime_t();
     tm = gmtime(&ct);
index 3d8938ccffefe924779e614842e21be871a04572..3827daf903337dcf4f713334abaf68fbeb5503ae 100644 (file)
@@ -268,7 +268,6 @@ mapsend_read()
 static void
 mapsend_waypt_pr(const Waypoint* waypointp)
 {
-  unsigned int c = 0;
   double falt;
   static int cnt = 0;
   QString sn = global_opts.synthesize_shortnames ?
@@ -296,7 +295,7 @@ mapsend_waypt_pr(const Waypoint* waypointp)
 
   // This is funny looking to ensure that no more than 30 bytes
   // get written to the file.
-  c = waypointp->description.length();
+  unsigned int c = waypointp->description.length();
   if (c > 30) {
     c = 30;
   }
index 45a3c508ed05238d7d7af95c4efef30631e18411..3c8b5a4af4192cdf72a13e2a645aa8d81b084fe0 100644 (file)
@@ -780,10 +780,8 @@ mps_waypoint_w_unique_wrapper(const Waypoint* wpt)
 static void
 mps_route_wpt_w_unique_wrapper(const Waypoint* wpt)
 {
-  Waypoint* wptfound = nullptr;
-
   /* Search for this waypoint in the ones already written */
-  wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname));
+  Waypoint* wptfound = mps_find_wpt_q_by_name(&written_wpt_head, CSTRc(wpt->shortname));
   if (wptfound == nullptr)
     /* so, not a real wpt, so must check route wpts already written as reals */
   {
diff --git a/ozi.cc b/ozi.cc
index abceebe51a3b101e37baf48f1c6704b77b4586b1..d196a5ea1ad6c2f64075a48eca8ef2f1f6852f61 100644 (file)
--- a/ozi.cc
+++ b/ozi.cc
@@ -869,10 +869,9 @@ ozi_waypt_pr(const Waypoint* wpt)
   QString description;
   QString shortname;
   int faked_fsdata = 0;
-  ozi_fsdata* fs = nullptr;
   int icon = 0;
 
-  fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
+  ozi_fsdata* fs = (ozi_fsdata*) fs_chain_find(wpt->fs, FS_OZI);
 
   if (!fs) {
     fs = ozi_alloc_fsdata();
index 08af16c7e2e25be5c2468a82119a491cd08125f8..f5d89c6d6995f75fc05c530937f887142b6f39b9 100644 (file)
@@ -230,18 +230,15 @@ void PolygonFilter::process()
 
   olat = olon = lat1 = lon1 = lat2 = lon2 = BADVAL;
   while ((line = gbfgetstr(file_in))) {
-    char* pound = nullptr;
-    int argsfound = 0;
-
     fileline++;
 
-    pound = strchr(line, '#');
+    char* pound = strchr(line, '#');
     if (pound) {
       *pound = '\0';
     }
 
     lat2 = lon2 = BADVAL;
-    argsfound = sscanf(line, "%lf %lf", &lat2, &lon2);
+    int argsfound = sscanf(line, "%lf %lf", &lat2, &lon2);
 
     if (argsfound != 2 && strspn(line, " \t\n") < strlen(line)) {
       warning(MYNAME
index b485177e44440e038a1e6c7ceb11018a8bace098..360ce89f7964aba0555131e0b9d2c56d279840a9 100644 (file)
@@ -504,8 +504,6 @@ psit_track_r(gbfile* psit_file, route_head**)
   unsigned int trk_num;
 
   struct tm tmTime;
-  time_t dateTime = 0;
-  route_head* track_head = nullptr;
   Waypoint* thisWaypoint;
 
   psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), ltrimEOL);
@@ -518,7 +516,7 @@ psit_track_r(gbfile* psit_file, route_head**)
   rtrim(trkname);
 
   trk_num = 0;
-  track_head = nullptr;
+  route_head* track_head = nullptr;
 
   psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
 
@@ -557,7 +555,7 @@ psit_track_r(gbfile* psit_file, route_head**)
              &(tmTime.tm_sec));
 
       tmTime.tm_isdst = 0;
-      dateTime = mkgmtime(&tmTime);
+      time_t dateTime = mkgmtime(&tmTime);
 
       psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace);
 
index d1cc2ff7df4861c642ae24294b02e5404686d131..a6b0e7eb6cb068969f8010e5542e704d766ffe99 100644 (file)
@@ -130,7 +130,6 @@ my_read()
   struct ll mylatlon;
   uint16_t coordcount;
   route_head* track_head = nullptr;
-  route_head* old_track_head = nullptr;
   Waypoint* wpt_tmp;
   char* routename = nullptr;
   double seglen = 0.0;
@@ -139,7 +138,6 @@ my_read()
   double totaldist = 0.0;
   double oldlat = 0;
   double oldlon = 0;
-  int first = 0;
 
   ReadShort(infile);           /* magic */
   version = ReadShort(infile);
@@ -311,7 +309,7 @@ my_read()
       }
     }
     while (count) {
-      old_track_head = nullptr;
+      route_head* old_track_head = nullptr;
       ReadShort(infile);
       recsize = ReadLong(infile);
       record = ReadRecord(infile, recsize);
@@ -359,7 +357,7 @@ my_read()
         coordcount--;
       }
 
-      first = 1;
+      int first = 1;
 
       while (coordcount) {
         double lat;
diff --git a/sbn.cc b/sbn.cc
index a8e225a71fc880f2873bc0ee7607fe5f88228fe6..4ef6eb4a00be945c978b25f6fc993f670e20113c 100644 (file)
--- a/sbn.cc
+++ b/sbn.cc
@@ -240,8 +240,7 @@ decode_sbn_position(const unsigned char* buffer, Waypoint* waypt)
 static Waypoint*
 decode_sbn_record(unsigned char* buffer)
 {
-  Waypoint* waypt = nullptr;
-  waypt = new Waypoint;
+  Waypoint* waypt = new Waypoint;
 
   if (is_sbn_valid(buffer)) {
     waypt->fix = decode_sbn_mode(buffer + 3);
index eba361d24447d325ec0467f8850a2cb87e8ddd1a..4c60e165210a549324e65769a0674ffa42ad3d76 100644 (file)
@@ -486,7 +486,7 @@ skytraq_configure_logging()
 {
   // an0008-1.4.14: logs if
   // (dt > tmin & dd >= dmin & v >= vmin) | dt > tmax | dd > dmax | v > vmax
-  unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000, nn=0;
+  unsigned int tmin=6, tmax=3600, dmin=0, dmax=10000;
   static uint8_t MSG_LOG_CONFIGURE_CONTROL[] = {
     0x18,                      // message_id
     0x00, 0x00, 0x0e, 0x10,    // max_time: was 0x0000ffff (big endian!)
@@ -501,7 +501,7 @@ skytraq_configure_logging()
 
   if (opt_configure_logging) {
     if (*opt_configure_logging) {
-      nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax);
+      unsigned int nn = sscanf(opt_configure_logging, "%u:%u:%u:%u", &tmin, &tmax, &dmin, &dmax);
       if (nn>3) {
         db(0, "Reconfiguring logging to: tmin=%u, tmax=%u, dmin=%u, dmax=%u\n", tmin, tmax, dmin, dmax);
         be_write32(MSG_LOG_CONFIGURE_CONTROL+5, tmin);
@@ -1060,7 +1060,6 @@ skytraq_read_tracks()
   int opt_first_sector_val = atoi(opt_first_sector);
   int opt_last_sector_val = atoi(opt_last_sector);
   int multi_read_supported = 1;
-  uint8_t* buffer = nullptr;
   gbfile* dumpfile = nullptr;
 
   state_init(&st);
@@ -1100,7 +1099,7 @@ skytraq_read_tracks()
     }
   }
 
-  buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6);
+  uint8_t* buffer = (uint8_t*) xmalloc(SECTOR_SIZE*read_at_once+sizeof(SECTOR_READ_END)+6);
   // m.ad/090930: removed code that tried reducing read_at_once if necessary since doesn't work with xmalloc
 
   if (opt_dump_file) {
index 61fe33243328cbe47d7e2ef81d034a2e3322a8ac..5aa984da7ba942ee6f78d8d23b68237419301ae8 100644 (file)
@@ -95,22 +95,20 @@ void SimplifyRouteFilter::routesimple_waypt_pr(const Waypoint* wpt)
 void SimplifyRouteFilter::compute_xte(struct xte* xte_rec)
 {
   const Waypoint* wpt3 = xte_rec->intermed->wpt;
-  const Waypoint* wpt1 = nullptr;
-  const Waypoint* wpt2 = nullptr;
   double frac, reslat, reslon;
   /* if no previous, this is an endpoint and must be preserved. */
   if (!xte_rec->intermed->prev) {
     xte_rec->distance = HUGEVAL;
     return;
   }
-  wpt1 = xte_rec->intermed->prev->wpt;
+  const Waypoint* wpt1 = xte_rec->intermed->prev->wpt;
 
   /* if no next, this is an endpoint and must be preserved. */
   if (!xte_rec->intermed->next) {
     xte_rec->distance = HUGEVAL;
     return;
   }
-  wpt2 = xte_rec->intermed->next->wpt;
+  const Waypoint* wpt2 = xte_rec->intermed->next->wpt;
 
   if (xteopt) {
     xte_rec->distance = radtomiles(linedist(
index 6aa568eaaf75b697a9fbd68fa01bba1eb5261d16..94f1d068b2884c66ce3de13710a9a59d2fd2b901 100644 (file)
--- a/stmsdf.cc
+++ b/stmsdf.cc
@@ -177,13 +177,12 @@ static void
 finalize_tracks(void)
 {
   Waypoint** list;
-  int count = 0;
   queue* elem, *tmp;
   int index;
   route_head* track = nullptr;
   int trackno = 0;
 
-  count = 0;
+  int count = 0;
   QUEUE_FOR_EACH(&trackpts, elem, tmp) {
     count++;
   };
diff --git a/text.cc b/text.cc
index 962034361d94d01048ac35cd2b3d61fcff144409..489e6a26adde3f1e63bf53889c5ad6de7c3de88c 100644 (file)
--- a/text.cc
+++ b/text.cc
@@ -174,15 +174,12 @@ text_disp(const Waypoint* wpt)
 
   if (fs_gpx && fs_gpx->tag) {
     xml_tag* root = fs_gpx->tag;
-    xml_tag* curlog = nullptr;
-    xml_tag* logpart = nullptr;
-    curlog = xml_findfirst(root, "groundspeak:log");
+    xml_tag* curlog = xml_findfirst(root, "groundspeak:log");
     while (curlog) {
       time_t logtime = 0;
-      struct tm* logtm = nullptr;
       gbfprintf(file_out, "\n");
 
-      logpart = xml_findfirst(curlog, "groundspeak:type");
+      xml_tag* logpart = xml_findfirst(curlog, "groundspeak:type");
       if (logpart) {
         gbfputs(logpart->cdata, file_out);
         gbfputs(" by ", file_out);
@@ -197,7 +194,7 @@ text_disp(const Waypoint* wpt)
       logpart = xml_findfirst(curlog, "groundspeak:date");
       if (logpart) {
         logtime = xml_parse_time(logpart->cdata).toTime_t();
-        logtm = localtime(&logtime);
+        struct tm* logtm = localtime(&logtime);
         if (logtm) {
           gbfprintf(file_out,
                     "%4.4d-%2.2d-%2.2d\n",
@@ -209,10 +206,9 @@ text_disp(const Waypoint* wpt)
 
       logpart = xml_findfirst(curlog, "groundspeak:log_wpt");
       if (logpart) {
-        char* coordstr = nullptr;
         double lat = 0;
         double lon = 0;
-        coordstr = xml_attribute(logpart, "lat");
+        char* coordstr = xml_attribute(logpart, "lat");
         if (coordstr) {
           lat = atof(coordstr);
         }
@@ -227,10 +223,8 @@ text_disp(const Waypoint* wpt)
 
       logpart = xml_findfirst(curlog, "groundspeak:text");
       if (logpart) {
-        char* encstr = nullptr;
-        int encoded = 0;
-        encstr = xml_attribute(logpart, "encoded");
-        encoded = (toupper(encstr[0]) != 'F');
+        char* encstr = xml_attribute(logpart, "encoded");
+        int encoded = (toupper(encstr[0]) != 'F');
 
         QString s;
         if (txt_encrypt && encoded) {
index b5d90050dd40fbe75c3a961c96e8b6514ac39430..929e2193e6fce2a190fdaea47a526414bdc06530 100644 (file)
--- a/tomtom.cc
+++ b/tomtom.cc
@@ -373,12 +373,10 @@ compute_blocks(struct hdr* start, int count,
   newblock->maxlat = maxlat;
   newblock->size = 4 * 5 + 1;   /* hdr is 5 longs, 1 char */
   if (count < 20) {
-    Waypoint* wpt = nullptr;
-
     for (int i = 0; i < count; i++) {
       newblock->size += 4 * 3 + 1;
       /* wpt const part 3 longs, 1 char */
-      wpt = start[i].wpt;
+      Waypoint* wpt = start[i].wpt;
       newblock->size += wpt->description.length() + 1;
     }
   } else {
diff --git a/tpo.cc b/tpo.cc
index c4c29a3cf02dd6f9a5f54e15b58c527eb532a785..a8a4ff1c8c70f9dfd29aeb681bc917c5e0e1f1d1 100644 (file)
--- a/tpo.cc
+++ b/tpo.cc
@@ -622,7 +622,6 @@ static void tpo_process_tracks()
     int lon = 0;
     route_head* track_temp;
     char rgb[7],bgr[7];
-    int bbggrr = 0;
 
     // Allocate the track struct
     track_temp = route_head_alloc();
@@ -652,7 +651,7 @@ static void tpo_process_tracks()
     // RGB line_color expressed for html=rrggbb and kml=bbggrr - not assigned before 2012
     sprintf(rgb,"%02x%02x%02x",styles[track_style].color[0],styles[track_style].color[1],styles[track_style].color[2]);
     sprintf(bgr,"%02x%02x%02x",styles[track_style].color[2],styles[track_style].color[1],styles[track_style].color[0]);
-    bbggrr = styles[track_style].color[2] << 16 | styles[track_style].color[1] << 8 | styles[track_style].color[0];
+    int bbggrr = styles[track_style].color[2] << 16 | styles[track_style].color[1] << 8 | styles[track_style].color[0];
     track_temp->line_color.bbggrr = bbggrr;
 
     // track texture (dashed=1, solid=0) mapped into opacity - not assigned before 2012
@@ -1191,7 +1190,6 @@ static void tpo_process_routes()
   // Read/process each route in the file
   //
   for (unsigned int ii = 0; ii < route_count; ii++) {
-    unsigned int name_length = 0;
     unsigned int waypoint_cnt;
     route_head* route_temp;
 
@@ -1208,7 +1206,7 @@ static void tpo_process_routes()
 
 //UNKNOWN DATA LENGTH
     // Fetch name length
-    name_length = tpo_read_int();
+    unsigned int name_length = tpo_read_int();
     QString route_name;
     if (name_length) {
       gbfread(route_name, 1, name_length, tpo_file_in);
index a7a57772f5b8a8d6a93fbadfdeff21fd1ee530be..69c2344eb3eab6533ab9083348c261f2832eaf05 100644 (file)
--- a/unicsv.cc
+++ b/unicsv.cc
@@ -517,7 +517,6 @@ unicsv_fondle_header(QString s)
 {
   // TODO: clean up this back and forth between QString and char*.
   char* buf = nullptr;
-  char* cbuf_start = nullptr;
   const cet_cs_vec_t* ascii = &cet_cs_vec_ansi_x3_4_1968;      /* us-ascii */
 
   /* Convert the entire header to lower case for convenience.
@@ -531,7 +530,7 @@ unicsv_fondle_header(QString s)
   } else if (s.contains('|')) {
     unicsv_fieldsep = "|";
   }
-  cbuf_start = xstrdup(s.toLower());
+  char* cbuf_start = xstrdup(s.toLower());
   const char* cbuf = cbuf_start;
 
   /* convert the header line into native ascii */
@@ -628,7 +627,6 @@ unicsv_rd_deinit()
 static void
 unicsv_parse_one_line(char* ibuf)
 {
-  Waypoint* wpt = nullptr;
   int column;
   int  utm_zone = -9999;
   double utm_easting = 0;
@@ -652,7 +650,7 @@ unicsv_parse_one_line(char* ibuf)
   int ns = 1;
   int ew = 1;
   geocache_data* gc_data = nullptr;
-  wpt = new Waypoint;
+  Waypoint* wpt = new Waypoint;
   wpt->latitude = unicsv_unknown;
   wpt->longitude = unicsv_unknown;
   memset(&ymd, 0, sizeof(ymd));
diff --git a/v900.cc b/v900.cc
index aaa680ebfe3207c14c62046d62eae63a29826faf..ee6e2e57e37cd59178f2a453a6efd25796738a57 100644 (file)
--- a/v900.cc
+++ b/v900.cc
@@ -211,7 +211,6 @@ v900_read()
     struct one_line_advanced_mode adv;
     char text[200]; /* used to read the header line, which is normal text */
   } line;
-  int is_advanced_mode = 0;
   int lc = 0;
   route_head* track;
 
@@ -226,7 +225,7 @@ v900_read()
   if (!fgets(line.text, sizeof(line), fin)) {
     fatal("v900: error reading header (first) line from input file\n");
   }
-  is_advanced_mode = (nullptr != strstr(line.text,"PDOP")); /* PDOP field appears only in advanced mode */
+  int is_advanced_mode = (nullptr != strstr(line.text,"PDOP")); /* PDOP field appears only in advanced mode */
 
   v900_log("header line: %s",line.text);
   v900_log("is_advance_mode=%d\n",is_advanced_mode);
diff --git a/vecs.cc b/vecs.cc
index 4b9e83cc3e632376c4d0e4380ab2e119cebf9141..b33e01d6a7fdaf1fb470be4cf1881e84c61674d4 100644 (file)
--- a/vecs.cc
+++ b/vecs.cc
@@ -1535,10 +1535,9 @@ disp_vecs()
 {
   vecs_t** svp;
   int vc;
-  int i = 0;
 
   svp = sort_and_unify_vecs(&vc);
-  for (i=0; i<vc; i++) {
+  for (int i = 0; i<vc; i++) {
     if (svp[i]->vec->type == ff_type_internal)  {
       continue;
     }
@@ -1562,10 +1561,9 @@ disp_vec(const char* vecname)
 {
   vecs_t** svp;
   int vc;
-  int i = 0;
 
   svp = sort_and_unify_vecs(&vc);
-  for (i=0; i<vc; i++) {
+  for (int i = 0; i<vc; i++) {
     if (case_ignore_strcmp(svp[i]->name, vecname))  {
       continue;
     }
index 715780cd6320b2b02f4f5f1443586c56924b1a5f..4ba5e3c710ce766d7039649a08981c502fd1114c 100644 (file)
@@ -68,21 +68,8 @@ rd_deinit()
 static void
 vitosmt_read()
 {
-  long  version  =0;
-  long  subversion =0;
-  long  check1  =-1;
-  long  check2  =-2;
-  long  check3  =-3;
   route_head* route_head =nullptr;
-  Waypoint* wpt_tmp =nullptr;
-  unsigned char* timestamp =nullptr;
   struct tm tmStruct;
-  double speed = 0.0;
-  double course = 0.0;
-  double pdop = 0.0;
-  unsigned char gpsfix = 0;
-  unsigned char gpsvalid = 0;
-  unsigned char gpssats = 0;
   int  serial  =0;
 
 
@@ -90,13 +77,13 @@ vitosmt_read()
   /*
    * 24 bytes header
    */
-  version = gbfgetint32(infile); /* 2 */
-  subversion = gbfgetint32(infile); /* 1000 */
+  long version = gbfgetint32(infile); /* 2 */
+  long subversion = gbfgetint32(infile); /* 1000 */
   count = gbfgetint32(infile); /* n */
-  check1 = gbfgetint32(infile); /* 0 */
-  check2 = gbfgetint32(infile); /* not sure */
+  long check1 = gbfgetint32(infile); /* 0 */
+  long check2 = gbfgetint32(infile); /* not sure */
   (void) check2; // silence warning.
-  check3 = gbfgetint32(infile); /* n */
+  long check3 = gbfgetint32(infile); /* n */
 
   if (version!=vitosmt_version) {
 
@@ -130,16 +117,16 @@ vitosmt_read()
     double latrad = gbfgetdbl(infile); /* WGS84 latitude in radians */
     double lonrad = gbfgetdbl(infile); /* WGS84 longitude in radians */
     double elev = gbfgetdbl(infile); /* elevation in meters */
-    timestamp = ReadRecord(infile,5); /* UTC time yr/mo/dy/hr/mi */
+    unsigned char* timestamp = ReadRecord(infile,5); /* UTC time yr/mo/dy/hr/mi */
     double seconds = gbfgetdbl(infile); /* seconds */
-    speed = gbfgetdbl(infile);    /* speed in knots */
-    course = gbfgetdbl(infile); /* course in degrees */
-    pdop = gbfgetdbl(infile); /* dilution of precision */
-    gpsfix = gbfgetc(infile); /* fix type x08,x10, x20 */
-    gpsvalid = gbfgetc(infile); /* fix is valid */
-    gpssats = gbfgetc(infile); /* number of sats */
+    double speed = gbfgetdbl(infile);    /* speed in knots */
+    double course = gbfgetdbl(infile); /* course in degrees */
+    double pdop = gbfgetdbl(infile); /* dilution of precision */
+    unsigned char gpsfix = gbfgetc(infile); /* fix type x08,x10, x20 */
+    unsigned char gpsvalid = gbfgetc(infile); /* fix is valid */
+    unsigned char gpssats = gbfgetc(infile); /* number of sats */
 
-    wpt_tmp = new Waypoint;
+    Waypoint* wpt_tmp = new Waypoint;
 
     wpt_tmp->latitude =DEG(latrad);
     wpt_tmp->longitude =DEG(lonrad);
@@ -223,12 +210,11 @@ wr_deinit()
 static void
 vitosmt_waypt_pr(const Waypoint* waypointp)
 {
-  unsigned char*  workbuffer =nullptr;
   size_t  position =0;
   double  seconds  =0;
 
   ++count;
-  workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
+  unsigned char*  workbuffer = (unsigned char*) xcalloc(vitosmt_datasize,1);
 
   WriteDouble(&workbuffer[position], RAD(waypointp->latitude));
   position += sizeof(double);
@@ -302,9 +288,7 @@ vitosmt_waypt_pr(const Waypoint* waypointp)
 static void
 vitosmt_write()
 {
-  unsigned char* workbuffer = nullptr;
-
-  workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
+  unsigned char* workbuffer = (unsigned char*) xcalloc(vitosmt_headersize,1);
 
   count = 0;
 
index 887bdc8987e1d264e5b7c181dccb8a95d8be0178..27ff8526bd2024b1e3d67b33cf830279ac165592 100644 (file)
@@ -57,13 +57,11 @@ rd_deinit()
 static void
 vitovtt_read()
 {
-  route_head* route_head= nullptr;
-  Waypoint* wpt_tmp = nullptr;
   struct tm tmStruct;
 
   memset(&tmStruct, 0, sizeof(tmStruct));
 
-  route_head = route_head_alloc();
+  route_head* route_head = route_head_alloc();
   track_add_head(route_head);
 
   /* Read the header. */
@@ -90,7 +88,7 @@ vitovtt_read()
     int course = gbfgetint16(infile);
     int status = gbfgetint32(infile);
 
-    wpt_tmp = new Waypoint;
+    Waypoint* wpt_tmp = new Waypoint;
 
     wpt_tmp->latitude= scaled_lat / vitovtt_latitudescale;
     wpt_tmp->longitude= scaled_lon / vitovtt_longitudescale;
index 2850474d72a7aaf35f60971374c4dee65d31c7ca..ca6ce26a1c323fd20ed4177f8f378ce37072327a 100644 (file)
@@ -566,7 +566,6 @@ static int wbt200_data_chunk(struct read_state* st, const void* buf, int fmt)
   uint32_t   tim;
   double     lat, lon, alt;
   time_t     rtim;
-  Waypoint*   tpt     = nullptr;
   const char* bp      = (const char*) buf;
   size_t     buf_used = fmt_version[fmt].reclen;
 
@@ -595,7 +594,7 @@ static int wbt200_data_chunk(struct read_state* st, const void* buf, int fmt)
     st->route_head_ = nullptr;
   }
 
-  tpt = make_trackpoint(st, lat, lon, alt, rtim);
+  Waypoint*   tpt = make_trackpoint(st, lat, lon, alt, rtim);
 
   if (nullptr == st->route_head_) {
     db(1, "New Track\n");
@@ -802,7 +801,6 @@ static int wbt201_data_chunk(struct read_state* st, const void* buf)
   uint16_t    flags;
   double      lat, lon, alt;
   time_t      rtim;
-  Waypoint*    tpt     = nullptr;
   const char*  bp      = (const char*) buf;
 
   /* Zero records are skipped */
@@ -834,7 +832,7 @@ static int wbt201_data_chunk(struct read_state* st, const void* buf)
       st->route_head_ = nullptr;
     }
 
-    tpt = make_trackpoint(st, lat, lon, alt, rtim);
+    Waypoint*    tpt = make_trackpoint(st, lat, lon, alt, rtim);
 
     if (nullptr == st->route_head_) {
       db(1, "New Track\n");
index 67ad63f3098c465acedbf11abc0c9397dc82129a..7db6cea4bcdcc83ffd40d7c48754cbf035fe44c7 100644 (file)
@@ -150,11 +150,10 @@ static long tosscount=0;
 
 void wfff_e(xg_string, const QXmlStreamAttributes*)
 {
-  Waypoint*    wpt_tmp         =nullptr;
   char         desc[255]       ="\0";
 
   if ((ap_hdop>=1)&&(ap_hdop<50)) { // Discard invalid GPS fix
-    wpt_tmp = new Waypoint;
+    Waypoint*  wpt_tmp = new Waypoint;
 
     if (snmac) {
       wpt_tmp->shortname = ap_mac;
diff --git a/xcsv.cc b/xcsv.cc
index 5359fb61d0a4c826e5b6d8deb7f025f37488b5fe..fb2dd951d73fa96fcc34c7a97eba3c3b9b1bf4fb 100644 (file)
--- a/xcsv.cc
+++ b/xcsv.cc
@@ -112,7 +112,6 @@ xcsv_destroy_style(void)
 {
   queue* elem, *tmp;
   field_map_t* fmp;
-  int internal = 0;
 
   /*
    * If this xcsv_file struct came from a file we can free it all.
@@ -184,7 +183,7 @@ xcsv_destroy_style(void)
   }
 
   /* return everything to zeros */
-  internal = xcsv_file.is_internal;
+  int internal = xcsv_file.is_internal;
   xcsv_file.is_internal = internal;
 }
 
index 605b92eb6f9b075c7e8cff9555d34bbcd7494893..c17916a9aaa6a053ee965b4633f024a8b77d40f2 100644 (file)
--- a/xmltag.cc
+++ b/xmltag.cc
@@ -29,7 +29,6 @@
 static void
 free_xml_tag(xml_tag* tag)
 {
-  xml_tag* next = nullptr;
   char** ap;
 
   while (tag) {
@@ -46,7 +45,7 @@ free_xml_tag(xml_tag* tag)
       xfree(tag->attributes);
     }
 
-    next = tag->sibling;
+    xml_tag* next = tag->sibling;
     delete tag;
     tag = next;
   }
@@ -56,15 +55,12 @@ free_xml_tag(xml_tag* tag)
 static void
 copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent)
 {
-  xml_tag* res = nullptr;
-  char** ap = nullptr;
-
   if (!src) {
     *copy = nullptr;
     return;
   }
 
-  res = new xml_tag;
+  xml_tag* res = new xml_tag;
   *copy = res;
 
 //  memcpy(res, src, sizeof(xml_tag));
@@ -72,7 +68,7 @@ copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent)
   res->cdata = (src->cdata);
   res->parentcdata = (src->parentcdata);
   if (src->attributes) {
-    ap = src->attributes;
+    char** ap = src->attributes;
     int count = 0;
     while (*ap) {
       count++;
@@ -95,8 +91,6 @@ copy_xml_tag(xml_tag** copy, xml_tag* src, xml_tag* parent)
 static void
 convert_xml_tag(xml_tag* tag)
 {
-  char** ap = nullptr;
-
   if (tag == nullptr) {
     return;
   }
@@ -106,7 +100,7 @@ convert_xml_tag(xml_tag* tag)
   tag->cdata = tag->cdata;
   tag->parentcdata = tag->parentcdata;
 
-  ap = tag->attributes;
+  char** ap = tag->attributes;
   while (*ap) {
     *ap = cet_convert_string(*ap);
     ap++;